We present an algorithm which returns a shortest path and related number of entanglements for a given configuration of a polymeric system in 2 or 3 dimensions. Rubinstein and Helfand, and later Everaers et al. introduced a concept to extract primitive paths for dense polymeric melts made of linear chains (a multiple disconnected multibead ‘path’), where each primitive path is defined as a path connecting the (space-fixed) ends of a polymer under the constraint of non-interpenetration (excluded volume) between primitive paths of different chains, such that the multiple disconnected path fulfills a minimization criterion. The present algorithm uses geometrical operations and provides a—model independent—efficient approximate solution to this challenging problem. Primitive paths are treated as ‘infinitely’ thin (we further allow for finite thickness to model excluded volume), and tensionless lines rather than multibead chains, excluded volume is taken into account without a force law. The present implementation allows to construct a shortest multiple disconnected path (SP) for 2D systems (polymeric chain within spherical obstacles) and an optimal SP for 3D systems (collection of polymeric chains). The number of entanglements is then simply obtained from the SP as either the number of interior kinks, or from the average length of a line segment. Further, information about structure and potentially also the dynamics of entanglements is immediately available from the SP. We apply the method to study the ‘concentration’ dependence of the degree of entanglement in phantom chain systems. Program summary Title of program:Z Catalogue number:ADVG Program summary URL: http://cpc.cs.qub.ac.uk/summaries/ADVG Program obtainable from: CPC Program Library, Queen's University of Belfast, N. Ireland Computer for which the program is designed and others on which it has been tested: Silicon Graphics (Irix), Sun (Solaris), PC (Linux) Operating systems or monitors under which the program has been tested: UNIX, Linux Program language used: USANSI Fortran 77 and Fortran 90 Memory required to execute with typical data: 1 MByte No. of lines in distributed program, including test data, etc.: 10 660 No. of bytes in distributed program, including test data, etc.: 119 551 Distribution formet:tar.gz Nature of physical problem: The problem is to obtain primitive paths substantiating a shortest multiple disconnected path (SP) for a given polymer configuration (chains of particles, with or without additional single particles as obstacles for the 2D case). Primitive paths are here defined as in [M. Rubinstein, E. Helfand, J. Chem. Phys. 82 (1985) 2477; R. Everaers, S.K. Sukumaran, G.S. Grest, C. Svaneborg, A. Sivasubramanian, K. Kremer, Science 303 (2004) 823] as the shortest line (path) respecting ‘topological’ constraints (from neighboring polymers or point obstacles) between ends of polymers. There is a unique solution for the 2D case. For the 3D case it is unique if we construct a primitive path of a single chain embedded within fixed line obstacles [J.S.B. Mitchell, Geometric shortest paths and network optimization, in: J.-R. Sack, J. Urrutia (Eds.), Handbook of Computational Geometry, Elsevier, Amsterdam, 2000, pp. 633–701]. For a large 3D configuration made of several chains, short is meant to be the Euclidean shortest multiple disconnected path (SP) where primitive paths are constructed for all chains simultaneously. While the latter problem, in general, does not possess a unique solution, the algorithm must return a locally optimal solution, robust against minor displacements of the disconnected path and chain re-labeling. The problem is solved if the number of kinks (or entanglements Z), explicitly deduced from the SP, is quite insensitive to the exact conformation of the SP which allows to estimate Z with a small error. Efficient method of solution: Primitive paths are constructed from the given polymer configuration (a non-shortest multiple disconnected path, including obstacles, if present) by first replacing each polymer contour by a line with a number of ‘kinks’ (beads, nodes) and ‘segments’ (edges). To obtain primitive paths, defined to be uncrossable by any other objects (neighboring primitive paths, line or point obstacles), the algorithm minimizes the length of all primitive paths consecutively, until a final minimum Euclidean length of the SP is reached. Fast geometric operations rather than dynamical methods are used to minimize the contour lengths of the primitive paths. Neighbor lists are used to keep track of potentially intersecting segments of other chains. Periodic boundary conditions are employed. A finite small line thickness is used in order to make sure that entanglements are not ‘lost’ due to finite precision of representation of numbers. Restrictions on the complexity of the problem: For a single chain embedded within fixed line or point obstacles, the algorithm returns the exact SP. For more complex problems, the algorithm returns a locally optimal SP. Except for exotic, probably rare, configurations it turns out that different locally optimal SPs possess quite an identical number of nodes. In general, the problem constructing the SP is known to be NP-hard [J.S.B. Mitchell, Geometric shortest paths and network optimization, in: J.-R. Sack, J. Urrutia (Eds.), Handbook of Computational Geometry, Elsevier, Amsterdam, 2000, pp. 633–701], and we offer a solution which should suffice to analyze physical problems, and gives an estimate about the precision and uniqueness of the result (from a standard deviation by varying the parameter: cyclicswitch). The program is NOT restricted to handle systems for which segment lengths of the SP exceed half the box size. Typical running time: Typical running times are approximately two orders of magnitude shorter compared with the ones needed for a corresponding molecular dynamics approach, and scale mostly linearly with system size. We provide a benchmark table.